function main( ui ) {

	try {
		
		return selectAllEvents();
	}
	catch( e ) {
		return "{ exception:" + toJSON(e) + " }";
	}
}


function selectAllEvents() {

  var records = new JSONArray();

  var cmd = "select t from EventEntity t";
  
  var params = null;
  
    EntityManager.find(  
    cmd,  
    params,
     function(result) {
      
      for( var i = 0; i < result.size() ; ++i ) {
        
        records.put( JSONObject.wrap(result.get(i)) );
      }
      
    });
    
    var result = new JSONObject();
    
    result.put( "records", records );
    

    return result.toString() ;

}
